import React, { Component } from 'react';
import PropTypes from 'prop-types';
class TodoItem extends Component {
    constructor(props) {
        super(props)
        this.handleDelete = this.handleDelete.bind(this)
    }

    render() {
        const { test, content } = this.props;
        return (
            <div onClick={this.handleDelete}>
                {test}-{content}
            </div>
        )
    }

    handleDelete() {
        const { onItemDelete, index } = this.props;
        onItemDelete(index);
    }
}
TodoItem.propTypes = {
    content: PropTypes.string,
    onItemDelete: PropTypes.func,
    index: PropTypes.number.isRequired
}

TodoItem.defaultProps = {
    test: 'hello'
}

export default TodoItem